package cn.edu.zafu.bigdata.yeshuchang.xsglxt;

import java.util.Scanner;

public class StudentInfoSystem {
    private static StudentManager studentManager = new StudentManager();
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        while (true) {
            System.out.println("======= 学生信息管理系统 =======");
            System.out.println("1. 添加学生信息");
            System.out.println("2. 检索学生信息");
            System.out.println("3. 更新学生信息");
            System.out.println("4. 删除学生信息");
            System.out.println("5. 退出程序");
            System.out.print("请输入操作编号 (1-5): ");
            int choice = scanner.nextInt();
            scanner.nextLine(); // Consume newline left-over

            switch (choice) {
                case 1:
                    addStudent();
                    break;
                case 2:
                    studentManager.retrieveStudent();
                    break;
                case 3:
                    studentManager.updateStudent();
                    break;
                case 4:
                    studentManager.deleteStudent();
                    break;
                case 5:
                    System.out.println("退出程序...");
                    System.exit(0);
                    break;
                default:
                    System.out.println("无效的选项，请重新输入。");
            }
        }
    }

    private static void addStudent() {
        System.out.print("输入学号: ");
        String id = scanner.nextLine();
        System.out.print("输入姓名: ");
        String name = scanner.nextLine();
        System.out.print("输入电话: ");
        String phone = scanner.nextLine();
        Student student = new Student(id, name, phone);
        studentManager.addStudent(student);
    }
}
